package utility;

import java.awt.CardLayout;
import java.util.ArrayList;
import javax.swing.JPanel;

/**
 * Til card layout
 *
 * @author Brian
 */
public class PageHandler {

    private CardLayout layout;
    private JPanel main;

    /**
     * Constructor
     *
     * @param layout
     * @param main
     */
    public PageHandler(CardLayout layout, JPanel main) {
        this.layout = layout;
        this.main = main;
        this.layout = (CardLayout) (main.getLayout());
    }

    /**
     * Tilføj side
     *
     * @param panel
     * @param ref
     */
    public void addPage(JPanel panel, String ref) {
        main.add(panel, ref);
    }

    /**
     * Vis side
     *
     * @param ref
     */
    public void show(String ref) {
        layout.show(main, ref);
        main.revalidate();
    }
}
